package org.example.service.impl;

import org.example.mapper.AdminUserMapper;
import org.example.pojo.Doctor.Doctor;
import org.example.pojo.Doctor.Schedule;
import org.example.pojo.DoctorUser;
import org.example.pojo.Patient.PatientUser;
import org.example.pojo.User;
import org.example.service.AdminUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class AdminUserServiceImpl implements AdminUserService {

    @Autowired
    private AdminUserMapper adminUserMapper;
    @Override
    public List<PatientUser> getAllPatients() {
        return adminUserMapper.findUsersByRoleP("0"); // 0代表患者
    }
    @Override
    public List<DoctorUser> getAllDoctors() {
        return adminUserMapper.findUsersByRoleD("2"); // 2代表医生
    }

    @Override
    public PatientUser getPatientById(Integer patientId) {
        return adminUserMapper.findUserByIdAndRoleP(patientId);
    }

    @Override
    public Doctor getDoctorById(Integer doctorId) {
        return adminUserMapper.findUserByIdAndRoleD(doctorId);
    }

    @Override
    public void updatePatient(PatientUser patient) {
        adminUserMapper.updatePatient(patient);
    }

    @Override
    public DoctorUser updateDoctor(DoctorUser doctor) {
        adminUserMapper.updateDoctor(doctor);
        return doctor;
    }

    @Override
    public void deletePatient(Integer id) {
        adminUserMapper.deleteUserByIdAndRoleP(id, "0");
    }

    @Override
    public void deleteDoctor(Integer id) {
        adminUserMapper.deleteUserByIdAndRoleD(id, "2");
    }
    //获取医生排班信息
    @Override
    public List<Schedule> getDoctorSchedule(Date scheduleDate, Integer clinicId) {
        return adminUserMapper.getDoctorSchedule(scheduleDate,clinicId);
    }
    @Override
    public List<Schedule> getDoctorScheduleNull() {
        return adminUserMapper.getDoctorScheduleNull();
    }
    //通过日期查看看排班信息
    @Override
    public List<Schedule> getDoctorScheduleByDate(String scheduleDate) {
        return adminUserMapper.getDoctorScheduleByDate(scheduleDate);
    }
    //通过科室id查看看排班信息
    @Override
    public List<Schedule> getDoctorScheduleById(Integer clinicId) {
        return adminUserMapper.getDoctorScheduleById(clinicId);
    }
    //添加医生排班信息
    @Override
    public void addDoctorSchedule(Schedule schedule) {
        adminUserMapper.addDoctorSchedule(schedule);
    }
    //删除医生排班信息
    @Override
    public void deleteDoctorSchedule(Integer scheduleId) {
        adminUserMapper.deleteDoctorSchedule(scheduleId);
    }
    //更新医生排班信息
    @Override
    public void updateDoctorSchedule(Schedule schedule) {
        adminUserMapper.updateDoctorSchedule(schedule);
    }

}